#ifndef MY_STDEXCEPT_H_
#define MY_STDEXCEPT_H_

#include <exception/spw_exception.h>
#include <stdlib.h>
namespace spwstd {
namespace spwexcept {

class RuntimeError : public Exception {
public:
    //默认构造函数
    explicit RuntimeError(const char*);
    //默认拷贝
    explicit RuntimeError(const RuntimeError&) noexcept;
    RuntimeError& operator=(const RuntimeError& e) noexcept; 

    //析构函数
    virtual ~RuntimeError() = default;

    // 异常描述
    virtual const char* what() const noexcept { return except_msg; }
private:
    char except_msg[256];
};

class LogicError : public Exception {
public:
    //默认构造函数
    explicit LogicError(const char*);
    //默认拷贝
    explicit LogicError(const LogicError&) noexcept;
    LogicError& operator=(const LogicError& e) noexcept; 
    
    //析构函数
    virtual ~LogicError() = default;

    // 异常描述
    virtual const char* what() const noexcept { return except_msg; }
private:
    char except_msg[256];
};

// TODO: out_of_range, lenght_error不完整，
class OutOfRange : public LogicError {
public:
    explicit OutOfRange(const char* arg): LogicError{arg}{ };
    virtual ~OutOfRange(){ };
};

class LengthError : public LogicError {
public:
    explicit LengthError(const char* arg): LogicError{arg}{ };
    virtual ~LengthError(){ };
};

} // namespace myexcept
} // spwstd
#endif // MY_STDEXCEPT_H_
